package com.ls.kdlss.ui.bangbang;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gm.common.utils.ToastUtil;
import com.gm.lib.views.titlebar.AbTitleBar;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.ls.kdlss.R;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 邦邦我
 */

public class BangFragment extends Fragment {
    @Bind(R.id.title_bar)
    AbTitleBar titleBar;
    @Bind(R.id.xry_view)
    RecyclerView xry_view;

    CommonAdapter<String> commonAdapter;

    public static BangFragment getInstance() {
        return new BangFragment();
    }

    public int page = 0;
    private View view;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        view = inflater.inflate(R.layout.activity_follow, null);
        ButterKnife.bind(this, view);
        setViews();

        return view;
    }

    public void setViews() {

        titleBar.setTitleText("消息");

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(view.getContext());
        xry_view.setLayoutManager(linearLayoutManager);

        List<String> strings = new ArrayList<>();
        strings.add("");
        strings.add("");
        strings.add("");
        strings.add("");
        strings.add("");

        commonAdapter = new CommonAdapter<String>(view.getContext(), R.layout.cell_news, strings) {
            @Override
            protected void convert(ViewHolder holder, String s, int position) {

                switch (position) {

                    case 0:
                        holder.setImageResource(R.id.iv_biaoti,R.drawable.news_icon011);
                        holder.getView(R.id.ll_viewswww).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                TeachanswersActivity.launch(getContext());
                            }
                        });
                        break;
                    case 1:
                        holder.setImageResource(R.id.iv_biaoti,R.drawable.news_icon0222);
                        break;
                    case 2:
                        holder.setImageResource( R.id.iv_biaoti,R.drawable.news_icon0333);
                        break;
                    case 3:
                        holder.setImageResource( R.id.iv_biaoti,R.drawable.news_icon0444);
                        break;
                    case 4:
                        holder.setImageResource( R.id.iv_biaoti,R.drawable.news_icon0555);
                        break;
                }


            }
        };
        xry_view.setAdapter(commonAdapter);


    }


}
